/* 全局样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'PingFang SC', 'Helvetica Neue', Arial, sans-serif;
}

body {
    background-color: #f8f9fa;
    color: #333;
}

/* 头部样式 */
header {
    background-color: #4CAF50;
    color: white;
    padding: 15px 0;
}

.header-container {
    width: 90%;
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
}

.logo img {
    height: 50px;
    margin-right: 10px;
    background-color: white;
    border-radius: 50%;
    padding: 5px;
}

.logo h1 {
    font-size: 24px;
}

.search-bar {
    display: flex;
    width: 30%;
}

.search-bar input {
    padding: 8px;
    flex-grow: 1;
    width: auto;
    border-radius: 4px 0 0 4px;
    border: none;
}

.search-bar button {
    padding: 8px 15px;
    background-color: #2E7D32;
    color: white;
    border: none;
    border-radius: 0 4px 4px 0;
    cursor: pointer;
    min-width: 80px;
    white-space: nowrap;
}

.nav-links {
    display: flex;
    list-style: none;
}

.nav-links li {
    margin-left: 20px;
}

.nav-links a {
    color: white;
    text-decoration: none;
    font-weight: bold;
}

.nav-links a:hover {
    text-decoration: underline;
}

/* 主内容样式 */
main {
    width: 90%;
    max-width: 1200px;
    margin: 20px auto;
}

.category-container {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    margin-bottom: 20px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.category-title {
    font-size: 20px;
    margin-bottom: 15px;
    color: #2E7D32;
}

.categories {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.category {
    padding: 8px 15px;
    background-color: #f1f8e9;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s;
}

.category:hover {
    background-color: #dcedc8;
}

.products-container {
    background-color: white;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.products-title {
    font-size: 20px;
    margin-bottom: 20px;
    color: #2E7D32;
}

/* 统一产品网格和卡片样式 */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.product-card {
    border: 1px solid #eee;
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
    height: 100%; /* 卡片高度统一 */
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.product-image {
    width: 100%;
    background-color: #f8f9fa;
    overflow: hidden;
    position: relative;
}

.product-image img {
    width: 100%;
    height: auto;
    object-fit: cover;
    transition: transform 0.3s;
}

.product-image img:hover {
    transform: scale(1.05);
}

.product-info {
    padding: 15px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-name {
    font-size: 18px;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.product-price {
    font-size: 16px;
    color: #e65100;
    margin-bottom: 10px;
    margin-top: auto;
    font-weight: bold;
}

/* 关键修改：调整按钮位置和大小 */
.product-actions {
    display: flex;
    gap: 10px;
    justify-content: center;
    margin-top: 10px; /* 上移按钮 */
}

.add-to-cart, .buy-now {
    padding: 12px 20px; /* 增大按钮尺寸 */
    font-size: 14px; /* 增大字体 */
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: bold;
    transition: background-color 0.3s;
    min-width: 120px; /* 确保按钮有足够宽度 */
}

.add-to-cart {
    background-color: #4CAF50;
    color: white;
}

.add-to-cart:hover {
    background-color: #2E7D32;
}

.buy-now {
    background-color: #FF9800;
    color: white;
}

.buy-now:hover {
    background-color: #F57C00;
}

/* 页脚样式 */
footer {
    background-color: #2E7D32;
    color: white;
    text-align: center;
    padding: 15px 0;
    margin-top: 30px;
}

/* 商品详情页样式 */
.detail-container {
    max-width: 1200px;
    margin: 20px auto;
    padding: 0 20px;
}

.breadcrumb {
    margin-bottom: 20px;
    color: #666;
}

.breadcrumb a {
    color: #333;
    text-decoration: none;
}

.breadcrumb a:hover {
    color: #e4393c;
}

.product-detail {
    display: flex;
    gap: 30px;
    margin-bottom: 40px;
}

.detail-image {
    max-width: 500px;
    margin: 0 auto;
    aspect-ratio: 4/3;
    background-color: #f8f9fa;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

.detail-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.detail-info {
    flex: 1;
}

.detail-title {
    font-size: 24px;
    margin-bottom: 15px;
    color: #333;
}

.detail-price {
    background-color: #f3f3f3;
    padding: 10px 15px;
    margin-bottom: 20px;
    font-size: 18px;
}

.price-label {
    color: #666;
    margin-right: 10px;
}

.price-value {
    color: #e4393c;
    font-size: 24px;
    font-weight: bold;
}

.detail-stock {
    margin-bottom: 15px;
}

.stock-label {
    color: #666;
    margin-right: 10px;
}

.in-stock {
    color: #008000;
}

.out-of-stock {
    color: #e4393c;
}

.detail-supplier {
    margin-bottom: 20px;
}

.supplier-label {
    color: #666;
    margin-right: 10px;
}

.detail-features {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid #eee;
}

.detail-features h3 {
    margin-bottom: 10px;
}

.detail-actions {
    display: flex;
    align-items: center;
    gap: 20px;
}

.quantity-selector {
    display: flex;
    align-items: center;
}

.quantity-btn {
    width: 30px;
    height: 30px;
    border: 1px solid #ddd;
    background-color: #f5f5f5;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

#quantity {
    width: 50px;
    height: 30px;
    border: 1px solid #ddd;
    border-left: none;
    border-right: none;
    text-align: center;
}

/* 选项卡样式 */
.product-tabs {
    margin-bottom: 40px;
}

.tab-buttons {
    display: flex;
    border-bottom: 1px solid #ddd;
}

.tab-button {
    padding: 10px 20px;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-bottom: none;
    margin-right: 5px;
    cursor: pointer;
}

.tab-button.active {
    background-color: white;
    border-top: 2px solid #e4393c;
    color: #e4393c;
    font-weight: bold;
}

.tab-content {
    border: 1px solid #ddd;
    border-top: none;
    padding: 20px;
}

.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

.spec-table {
    width: 100%;
    border-collapse: collapse;
}

.spec-table td {
    padding: 10px;
    border: 1px solid #eee;
}

.spec-table tr:nth-child(even) {
    background-color: #f9f9f9;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .header-container {
        flex-direction: column;
        gap: 15px;
    }

    .search-bar {
        width: 100%;
    }

    .nav-links {
        width: 100%;
        justify-content: center;
    }

    .nav-links li {
        margin: 0 10px;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .product-card {
        height: auto;
    }

    .product-detail {
        flex-direction: column;
    }

    .detail-image {
        max-width: 100%;
    }

    /* 移动端按钮尺寸调整 */
    .add-to-cart, .buy-now {
        padding: 10px 16px;
        font-size: 13px;
        min-width: 100px;
    }
}

/* 骨架屏动画 */
@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}